//
//  UserBean.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/11.
//

//用户信息
import Foundation
import LeanCloud

class UserBean : ICloudTable, Identifiable {
    func getCloudTable() -> String {
        "User_"
    }
    
    var objectId: String? = nil
    var createdAt: CreatedAt? = nil
    var name:String? = nil
    var headUrl:String?=nil
    var vipExpiration:Int64 = 0//当vip过期时间大于现在，则代表有vip,如果负数，则直接代表永久
    var sex:Int = 0 // 0男孩，1女孩
    var qq:String?=nil
    var wx:String?=nil
    var phone:String?=nil
    var apple:String?=nil
    var tourist:String?=nil //游客
    var loginType:String? = nil
    var aiChatCount : Double = 0//ai数量
    var aiChatCountExpiration:Int64? = nil //ai次数 过期时间
    var folderConfig: FolderConfig? = nil
    var extraConfig: UserExtraConfig? = nil
    var vipSource : Int? = nil//vip来源
    public var aiChatModelMap : [String:AiModelCustomBean]? = nil  //新的ai模型
    var inviteCode: String? = nil//邀请码
    var inviteUserId: String? = nil//邀请者的userId
    var inviteCount:Int? = nil//已成功邀请人数。
    
    func getExtraConfig() -> UserExtraConfig {
        if extraConfig == nil {
            extraConfig = UserExtraConfig()
        }
        return extraConfig!
    }
    
    func getFolderConfig() -> FolderConfig {
        if folderConfig == nil {
            folderConfig = FolderConfig()
        }
        return folderConfig!
    }

    
    // 自定义反射
    func doCustomExcluded() -> [String?: Any?] {
        return doExcluded(subject: self, excluded: ["createdAt"])
    }
    
    func getSexStr() -> String {
        if sex == 1 {
            return "女"
        }
        return "男"
    }
    
    func getAiChatMode(key: String) -> AiModelCustomBean? {
        let value = aiChatModelMap?.first(where: {$0.key == key})?.value
        return value
    }
}
